<html xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:t="http://myfaces.apache.org/tomahawk"
      xmlns:v="http://shale.apache.org/validator">

<f:view>
<f:loadBundle var="text" basename="#{torrentForm.bundleName}"/>
    <head>
        <title>#{text['torrentDetail.title']}</title>
        <meta name="heading" content="#{text['torrentDetail.heading']}"/>
    </head>
<body id="torrentForm">

<h:form id="torrentForm" onsubmit="return validateTorrentForm(this)">
<h:inputHidden value="#{torrentForm.torrent.id}" id="id"/>
<h:panelGrid columns="3">
    <!-- todo: change this to read the identifier field from the other pojo -->
    <h:selectOneMenu value="#{torrentForm.torrent.owner}" id="owner" required="false" styleClass="select">
        <f:selectItems value="#{torrentForm.torrent.owner}"/>
    </h:selectOneMenu>

    <h:panelGroup styleClass="buttonBar bottom">
        <h:commandButton value="#{text['button.save']}" action="#{torrentForm.save}" id="save" styleClass="button"/>

        <c:if test="${not empty torrentForm.torrent.id}">
        <h:commandButton value="#{text['button.delete']}" action="#{torrentForm.delete}"
            id="delete" styleClass="button" onclick="bCancel=true; return confirmDelete('Torrent')"/>
        </c:if>

        <h:commandButton value="#{text['button.cancel']}" action="cancel" immediate="true"
            id="cancel" styleClass="button" onclick="bCancel=true"/>
    </h:panelGroup>
    <h:outputText/><h:outputText/>
</h:panelGrid>
</h:form>

<v:validatorScript functionName="validateTorrentForm"/>

<script type="text/javascript">
    //Form.focusFirstElement($('torrentForm'));
    highlightFormElements();
</script>

</body>
</f:view>
</html>
